package com.beiding.my.common.query;

import com.beiding.my.common.Bo;
import com.beiding.my.common.QuoteExpressionRegistry;

public class OuterCompareBinary extends OuterCompare{
    private String symbol;
    private String field;
    private Object value;

    public void setSymbol(String symbol) {
        this.symbol = symbol;
    }

    public void setField(String field) {
        this.field = field;
    }

    public void setValue(Object value) {
        this.value = value;
    }

    @Override
    protected String createExpression(QuoteExpressionRegistry registry, Class<? extends Bo> type, ParamHolderCreator paramHolderCreator, CreateResult createResult) {
        QuoteExpressionRegistry.QuoteExpression quoteExpression = registry.getQuoteExpression(type, field);
        createResult.quoteConditions.addAll(quoteExpression.getQuoteConditions());
        createResult.beTypes.addAll(quoteExpression.getBeTypes());
        if (value == null) {
            return quoteExpression.getExpression() + " is null";
        }
        String holder = paramHolderCreator.create();
        createResult.params.put(holder, value);
        return quoteExpression.getExpression() + " " + symbol + " :" + holder;
    }
}
